package com.alks.function.mapper.procurement;


import com.alks.entity.data.entity.*;
import com.alks.function.data.dto.procurement.*;
import com.alks.function.data.request.procurement.PackagMaterialRequest;
import com.alks.function.data.request.procurement.SdMaterialRequest;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

@Mapper
public interface BrandMaterialDefinitionMapper {

    /*品牌*/
    /*品牌增加*/
    int addBrand(@Param("companyId") String companyId, @Param("userName") String userName, @Param("style") String style);

    /*品牌明细-选择品牌-回显*/
    List<SdBrandDto> getBrandTypeList(@Param("companyId") String companyId, @Param("style") String style);


    /*品牌明细*/
    /**
     * 品牌明细查询
     * @param style
     * @param companyId
     * @return
     */
    List<PcPackStyleDto> getBrandMaterialListByStyle(@Param("style") String style, @Param("companyId") String companyId);

    /**
     * 品牌明细添加
     * @param pcPackStyle
     * @return
     */
    int addBrandMaterial(PcPackStyle pcPackStyle);

    /**
     * 品牌明细删除
     * @param style
     * @param companyId
     */
    int deleteBrandMaterial(@Param("style") String style, @Param("companyId") String companyId);


    /*包材分类明细*/
    /**
     * 包材分类明细查询
     * @param style
     * @param companyId
     * @return
     */
    List<PcPackStyleTypeDto> getPackageMaterialByStyle(@Param("style") String style, @Param("companyId") String companyId);

    /**
     * 品牌包材批量新增
     * @param pcPackStyleTypes
     */
    int addPackagMaterial(@Param("list") List<PcPackStyleType> pcPackStyleTypes);

    /**
     * 包材类别删除
     * @param request
     * @param style
     */
    void deletePackagMaterial(@Param("request") PackagMaterialRequest request, @Param("style") String style, @Param("companyId") String companyId);
    /*删除所有包材*/
    int deleteAllPackagMaterial(@Param("style") String style, @Param("companyId") String companyId);

    /**
     * 包材类别修改
     * @param request
     */
    int updatePackagMaterial(@Param("request") List<PackagMaterialRequest> request, @Param("companyId") String companyId, @Param("style") String style);

    /**
     * 包材类别批量修改
     */
    int updateBatchPackagMaterial(@Param("request") List<PackagMaterialRequest> brandMaterialList2, @Param("companyId") String companyId, @Param("style") String style);


    /*材料明细*/


    /**
     * 材料明细查询
     * @param style
     * @param typeName
     * @param companyId
     * @return
     */
    List<PcPackStyleTypeMtlDto> getMaterialList(@Param("style") String style, @Param("typeName") String typeName, @Param("companyId") String companyId, @Param("seqNo") Integer seqNo);


    /*查询该品牌的所有mtlNo*/
    List<PcPackStyleTypeMtlDto> getAllMaterialList(@Param("style") String style, @Param("companyId") String companyId);

    /**
     * 材料明细删除
     * @param materialDetail
     */
    void deleteMaterial(PcPackStyleTypeMtl materialDetail);

    /*删除所有材料明细*/
    int deleteAllMaterial(@Param("style") String style, @Param("companyId") String companyId);

    /*材料明细新增*/
    int addgetMaterialByMtlNo(PcPackStyleTypeMtl mtl);

    /*批量更新材料明细*/
    int addBatchMaterialDetail(@Param("request") List<PcPackStyleTypeMtl> mtls);

    /*材料明细：编辑（用量（比））*/
    int updateMaterialDetail(@Param("request") PcPackStyleTypeMtl mtl);

    /*装箱方式*/
    /**
     * 查询装箱方式
     * @param companyId
     * @return
     */
    @Select("select * from PC_PACK_TYPE where COMPANY_ID = #{companyId} ORDER BY SEQ_NO")
    List<PcPackTypeDto> getBoxingStyle(String companyId);

    /**
     * 定义装箱方式
     * @param pcPackTypes
     */
    void addBoxingStyle(@Param("list") ArrayList<PcPackType> pcPackTypes);


    /*物料资料建档*/
    /**
     * 物料资料建档:查询
     * @param companyId
     * @param request
     * @return
     */
    List<SdMaterialDto> getMaterialDataFilingList(@Param("companyId") String companyId, @Param("request") SdMaterialRequest request);

    /*物料资料建档:查询*/
    SdMaterialDto getMaterialData(SdMaterial sdMaterial);

    SdMaterialDto getMaterialMaxData(@Param("companyId") String companyId, @Param("mtlType") String mtlType);

    /*物料资料建档*/
    int addSdMaterial(@Param("request") SdMaterial sdMaterial);

    /*物料资料建档：编辑*/
    int updateSdMaterial(@Param("request") SdMaterial sdMaterial);

    @Select("select * from SD_MATERIAL where COMPANY_ID = #{companyId} and MTL_NO = #{mtlNo}")
    SdMaterial getMaterialDataFiling(String companyId, String mtlNo);

    @Delete("delete from SD_MATERIAL where COMPANY_ID = #{companyId} and MTL_NO = #{mtlNo} ")
    void deleteMaterialDataFiling(@Param("companyId") String companyId, @Param("mtlNo") String mtlNo);

    @Select("select STYLE from PC_PACK_STYLE where STYLE = #{style} and COMPANY_ID = #{companyId}")
    String getStyleByStyleAndCompany(@Param("style") String style, @Param("companyId") String companyId);


    @Select("select * from PC_PACK_STYLE_TYPE where STYLE = #{style} and TYPE_NAME=#{typeName} and COMPANY_ID = #{companyId} and SEQ_NO = #{seqNo}")
    PcPackStyleType getPackageMaterial(@Param("style") String style, @Param("seqNo") Integer seqNo, @Param("typeName") String typeName, @Param("companyId") String companyId);

    @Select("select * from PC_PACK_STYLE_TYPE_MTL where STYLE = #{style} and COMPANY_ID = #{companyId} and TYPE_NAME = #{typeName} and SEQ_NO = #{seqNo} and MTL_NO = #{mtlNo}")
    PcPackStyleTypeMtl getMaterialByMtlNo(@Param("style") String style, @Param("companyId") String companyId, @Param("mtlNo") String mtlNo, @Param("seqNo") Integer seqNo, @Param("typeName") String typeName);

    /*批量获取该品牌的所有mtlNo*/
    List<PcPackStyleTypeMtlDto> getMaterialListBYStyle(@Param("styleList") Set<String> styleList, @Param("companyId") String companyId);

}
